package com.qipay.baas.mapper;

import com.qipay.baas.model.WhiteIps;
import com.qipay.baas.model.WhiteIpsExample;
import java.util.List;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectKey;
import org.apache.ibatis.annotations.SelectProvider;
import org.apache.ibatis.annotations.Update;
import org.apache.ibatis.annotations.UpdateProvider;
import org.apache.ibatis.session.RowBounds;
import org.apache.ibatis.type.JdbcType;

public interface WhiteIpsMapper {
    @SelectProvider(type=WhiteIpsSqlProvider.class, method="countByExample")
    int countByExample(WhiteIpsExample example);

    @Delete({
        "delete from `white_ips`",
        "where `id` = #{id,jdbcType=BIGINT}"
    })
    int deleteByPrimaryKey(Long id);

    @Insert({
        "insert into `white_ips` (`cpid`, `ip_address`)",
        "values (#{cpid,jdbcType=BIGINT}, #{ipAddress,jdbcType=CHAR})"
    })
    @SelectKey(statement="SELECT LAST_INSERT_ID()", keyProperty="id", before=false, resultType=Long.class)
    int insert(WhiteIps record);

    @InsertProvider(type=WhiteIpsSqlProvider.class, method="insertSelective")
    @SelectKey(statement="SELECT LAST_INSERT_ID()", keyProperty="id", before=false, resultType=Long.class)
    int insertSelective(WhiteIps record);

    @SelectProvider(type=WhiteIpsSqlProvider.class, method="selectByExample")
    @Results({
        @Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true),
        @Result(column="cpid", property="cpid", jdbcType=JdbcType.BIGINT),
        @Result(column="ip_address", property="ipAddress", jdbcType=JdbcType.CHAR)
    })
    List<WhiteIps> selectByExampleWithRowbounds(WhiteIpsExample example, RowBounds rowBounds);

    @SelectProvider(type=WhiteIpsSqlProvider.class, method="selectByExample")
    @Results({
        @Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true),
        @Result(column="cpid", property="cpid", jdbcType=JdbcType.BIGINT),
        @Result(column="ip_address", property="ipAddress", jdbcType=JdbcType.CHAR)
    })
    List<WhiteIps> selectByExample(WhiteIpsExample example);

    @Select({
        "select",
        "`id`, `cpid`, `ip_address`",
        "from `white_ips`",
        "where `id` = #{id,jdbcType=BIGINT}"
    })
    @Results({
        @Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true),
        @Result(column="cpid", property="cpid", jdbcType=JdbcType.BIGINT),
        @Result(column="ip_address", property="ipAddress", jdbcType=JdbcType.CHAR)
    })
    WhiteIps selectByPrimaryKey(Long id);

    @UpdateProvider(type=WhiteIpsSqlProvider.class, method="updateByPrimaryKeySelective")
    int updateByPrimaryKeySelective(WhiteIps record);

    @Update({
        "update `white_ips`",
        "set `cpid` = #{cpid,jdbcType=BIGINT},",
          "`ip_address` = #{ipAddress,jdbcType=CHAR}",
        "where `id` = #{id,jdbcType=BIGINT}"
    })
    int updateByPrimaryKey(WhiteIps record);
}